package com.hotel.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.hotel.dao.mapper.HotelInfoMapper;
import com.hotel.entity.HotelInfo;
import com.hotel.entity.HotelInfoExample;
import com.hotel.service.HotelService;



@Service("hotelSelectService")
public class HotelServiceImpl implements HotelService{

	@Resource  
    private HotelInfoMapper hotelInfoMapper;
	
	@Override
	public List<HotelInfo> hotelSelect(String name) {
		HotelInfoExample example = new HotelInfoExample();
		HotelInfoExample.Criteria criteria = example.createCriteria();
		criteria.andNameLike("%"+name+"%");
		List<HotelInfo> list = hotelInfoMapper.selectByExample(example);
		
		
		return list;
	}

	@Override
	public List<HotelInfo> hotelRecommend() {
		HotelInfoExample example = new HotelInfoExample();
		HotelInfoExample.Criteria criteria = example.createCriteria();
		criteria.andIdIsNotNull();
		example.setOrderByClause("score");
		example.setSort("DESC");
		List<HotelInfo> list = hotelInfoMapper.selectByExample(example);
		return list;
	}

	@Override
	public HotelInfo hotelSelectById(int id) {
		HotelInfoExample example = new HotelInfoExample();
		HotelInfoExample.Criteria criteria = example.createCriteria();
		criteria.andIdEqualTo(id);
		List<HotelInfo> list = hotelInfoMapper.selectByExample(example);
		
		
		return list.get(0);
	}

}
